package com.zyj.ai_agent.demo.invoke;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.boot.CommandLineRunner;

public class SpringAiAiInvoke implements CommandLineRunner {

    @Resource
    private ChatModel dashscopeChatModel;

    @Override
    public void run(String... args) throws Exception {
        // TODO Auto-generated method stub
        // 调用dashscopeChatModel.call方法，传入一个Prompt对象，获取结果
        AssistantMessage assistantMessage = dashscopeChatModel.call(new Prompt("你好.我是程序员张艳津"))
                .getResult()
                .getOutput();
        // 打印assistantMessage的文本
        System.out.println(assistantMessage.getText());
    }
}
